package com.probiz.estore.system.dao.impl;

import java.util.List;

import com.probiz.estore.common.model.system.ShippingMethod;
import com.probiz.estore.core.dao.impl.HibernateGenericDaoImpl;
import com.probiz.estore.core.model.BaseObject;
import com.probiz.estore.system.dao.ShippingMethodDao;


/**
 * ShippingMethod Data Access Object (DAO) implementation.
 * Developer introduced interfaces should be declared here. Won't get overwritten.
*/
public class ShippingMethodDaoImpl extends HibernateGenericDaoImpl<ShippingMethod> implements ShippingMethodDao {
	protected void initFilterHqlMap() {
		filterHqlMap.put(BaseObject.FilterHqlName.DEFAULT, "select s from ShippingMethod s where s.deleted !=1 order by s.shippingMethodId desc");	
	}

	public ShippingMethod findShippingMethodByShippingMethodCode(
			String shippingMethodCode) {	
		String hql="from ShippingMethod s where s.shippingMethodCode=?";
		List<ShippingMethod> list=this.findByHql(hql, shippingMethodCode);
		if(list!=null&&list.size()>0){
			return list.get(0);
		}
		return null;
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.probiz.estore.system.dao.ShippingMethodDao#listAllActive()
	 */
	public List<ShippingMethod> listAllActive(){
		StringBuffer sb = new StringBuffer();
		sb.append("from ShippingMethod s where s.carrier.status = 1 and s.carrier.deleted=0 and s.status=1 and s.deleted=0 order by s.shippingMethodId desc");
		return this.findByHql(sb.toString());
	}
	
}